//app.js
App({
  onLaunch: function () {
    var that = this
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    // 登录
    wx.login({
      success: res => {
        wx.request({
          url: that.globalData.host + '/suser/authorization?code=' + res.code,
          method: 'get',
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          success: element => {
            if (element.data.status == 1) {
              if (element.data.data.phone != null && element.data.data.phone != '') {
                that.globalData.userId = element.data.data.id
                that.globalData.wxUserInfo = element.data.data
                that.globalData.openId = element.data.data.openId
              }
            } else {
              that.globalData.openId = element.data.data
            }
          }
        })
      }
    })
  },
  globalData: {
    // host:'https://shopping.metro-orientalplaza.cn/api', // 正式
    imgUrl: 'https://shopping.metro-orientalplaza.cn/file', // 正式
    host: 'http://192.168.2.2:8080/ZTwordMaven', // 本地
    // imgUrl:'http://39.98.185.89:8080/ZTwordMaven',// 本地
    wxInfo: null, //微信本地用户信息
    wxUserInfo: null, //微信用户信息
    userId: '', //用户id
    appid: "wx6d092b71cdd219d8",
    address: null,
    confirmOrder: null,
    openId: '',
  }
})